WebFontConfig = {
    google: { families: [ 'Lekton:400,700,400italic:latin,latin-ext', 'Montserrat:400,700:latin', 'Cardo:400italic:latin,latin-ext' ] }
};
(function () {
    var wf = document.createElement('script');
    wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
        '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    wf.type = 'text/javascript';
    wf.async = 'true';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(wf, s);
})();

//font-family: 'Lekton', sans-serif;
//400 - 400 italic - bold 700


$.FULLTOP = {};
$.FULLTOP.reference = '#fullUp';
$.FULLTOP.wrapper = '#fullUpWrapper';
$.FULLTOP.close = '#fullUpWrapperClose';
$.FULLTOP.referenceVideo = '#fullUpVideo';
$.FULLTOP.wrapperVideo = '#fullUpWrapperVideo';
$.FULLTOP.closeVideo = '#fullUpWrapperCloseVideo';
$.FULLTOP.referenceVideoPage = '#fullUpVideoPage';
$.FULLTOP.wrapperVideoPage = '#fullUpWrapperVideoPage';
$.FULLTOP.closeVideoPage = '#fullUpWrapperCloseVideoPage';
$.FULLTOP.videoStore = false;
$.FULLTOP.videoStorePage = false;
$.FULLTOP.videoStick = false;

$.FULLTOP.openframe = function () {
    $($.FULLTOP.reference).show();
};
$.FULLTOP.openframeVideo = function () {
    $('#big-video-control-play').animate({opacity: 1}, 0);
    $('#big-video-control-play').css({backgroundPosition: '0% 50%'});
    $($.FULLTOP.referenceVideo).show();
};
$.FULLTOP.openframeVideoPage = function () {
    $('#big-video-control-play').animate({opacity: 1}, 0);
    $('#big-video-control-play').css({backgroundPosition: '0% 50%'});
    $($.FULLTOP.referenceVideoPage).show();
};

$.FULLTOP.openwrapper = function () {
    TweenLite.to($($.FULLTOP.wrapper), 1, {css: {top: "0%"}, onComplete: function () {
        $($.FULLTOP.close).slideDown('fast');
    }});
};
$.FULLTOP.openwrapperVideo = function () {
    TweenLite.to($($.FULLTOP.wrapperVideo), 1, {css: {top: "0%"}, onComplete: function () {
        $($.FULLTOP.closeVideo).slideDown('fast');
    }});
};
$.FULLTOP.openwrapperVideoPage = function () {
    TweenLite.to($($.FULLTOP.wrapperVideoPage), 1, {css: {top: "0%"}, onComplete: function () {
        $($.FULLTOP.closeVideoPage).slideDown('fast');
    }});
};

$($.FULLTOP.close).click(function () {
    $(this).slideUp('fast');
    TweenLite.to($($.FULLTOP.wrapper), 1, {css: {top: "100%"}, onComplete: function () {
        //$($.FULLTOP.wrapper).empty();
        //$.FULLTOP.videoStore.getPlayer().pause();
        $($.FULLTOP.reference).hide();
    }});
    $.MENUNAV.showSticks();
});

$($.FULLTOP.close).hover(
    function () {
        $(this).addClass('closeHover');


        if (!$('html').hasClass('no-touch') && generalVideo.overrideCLose) {

            generalVideo.video1.pause();
            generalVideo.video2.pause();
            generalVideo.video3.pause();
            generalVideo.video4.pause();

            TweenLite.to($('#fullUpVideo'), 1, {css: {top: "-100%"}, onComplete: function () {
                $('#fullUpWrapperCloseVideo').slideUp('fast');
            }});
            TweenLite.to($('#fullUpWrapperVideo'), 1, {css: {top: "-100%"}, onComplete: function () {
            }});
        }

    },
    function () {
        $(this).removeClass('closeHover');
    }
);

$($.FULLTOP.closeVideo).click(function () {
    if (generalVideo.overrideCLose != true) {
        $.FULLTOP.videoStore.getPlayer().pause();
        $('#big-video-control-play').animate({opacity: 0}, 250);
        $(this).slideUp('fast');
        TweenLite.to($($.FULLTOP.wrapperVideo), 1, {css: {top: "100%"}, onComplete: function () {
            $($.FULLTOP.referenceVideo).hide();
        }});
        if ($.FULLTOP.videoStick) {
            $.MENUNAV.showSticks();
            $.FULLTOP.videoStick = false;
        }
        //playall sounds
        $.SLIDES.initSound('slideSound', 'play');
        $.SLIDES.initSound('bgSound', 'play');
        SOUNDS.active = true;
    }
});

$($.FULLTOP.closeVideo).hover(
    function () {
        $(this).addClass('closeHover');
    },
    function () {
        $(this).removeClass('closeHover');
    }
);

$('#fullUpWrapperCloseVideoPage').click(function () {
    if ($.FULLTOP.videoStorePage) {
        $.FULLTOP.videoStorePage.getPlayer().pause();
    }

    $('#big-video-control-play').animate({opacity: 0}, 250);
    $(this).slideUp('fast');
    TweenLite.to($('#fullUpWrapperVideoPage'), 1, {css: {top: "100%"}, onComplete: function () {
        $('#fullUpVideoPage').hide();
    }});
    //$.MENUNAV.showSticks();

    //playall sounds
    $.SLIDES.initSound('slideSound', 'play');
    $.SLIDES.initSound('bgSound', 'play');
    SOUNDS.active = true;
});
$($.FULLTOP.closeVideoPage).hover(
    function () {
        $(this).addClass('closeHover');
    },
    function () {
        $(this).removeClass('closeHover');
    }
);

$.FULLTOP.loadUrl = function ($urlToLoad, $mode, $dataObject) {

    if ($mode == 'player') {
        console.log('debug > player');
        $.FULLTOP.videoStick = true;
        $.MENUNAV.hideSticks();
        $.FULLTOP.openframeVideo();
        $.FULLTOP.loadVideo($dataObject.mp4, $dataObject.webm, $dataObject.poster);
        $.FULLTOP.openwrapperVideo();
        //stopall sounds
        $.SLIDES.initSound('slideSound', 'pause');
        $.SLIDES.initSound('bgSound', 'pause');
        SOUNDS.active = false;
    } else if ($mode == 'url') {
        console.log('debug > urkl');
        $.MENUNAV.hideSticks();
        $($.FULLTOP.wrapper).load($urlToLoad, function (response, status, xhr) {
            if (status == "error") {
                console.log("Sorry but there was an error: " + xhr.status + " " + xhr.statusText);
            } else {
                $.FULLTOP.openframe();
                $.FULLTOP.openwrapper();

                //sounds modifier
                $.SLIDES.initSound('slideSound', $dataObject.audio);
                $.SLIDES.initSound('bgSound', $dataObject.audio_bg);
            }
        });
    } else {
        console.log('debug > menu');
        $($.FULLTOP.wrapper).load($urlToLoad, function (response, status, xhr) {
            if (status == "error") {
                console.log("Sorry but there was an error: " + xhr.status + " " + xhr.statusText);
            } else {
                $.FULLTOP.openframe();
                $.FULLTOP.openwrapper();

                //sounds modifier
                $.SLIDES.initSound('slideSound', $dataObject.audio);
                $.SLIDES.initSound('bgSound', $dataObject.audio_bg);

            }
        });
    }

};

$.FULLTOP.loadVideo = function ($videoMp4, $videoOgv, $videoPoster) {


    if ($.FULLTOP.videoStore) {
        $.FULLTOP.videoStore.getPlayer().destroy();
        $.FULLTOP.videoStore = new $.BigVideo({baseVideoFrame: $.FULLTOP.wrapperVideo, posterBaseValue: ''});
        $.FULLTOP.videoStore.init();
        $.FULLTOP.videoStore.getPlayer().addEvent("ended", function () {
            $.FULLTOP.videoStore.getPlayer().pause();
            $.FULLTOP.videoStore.getPlayer().currentTime(0);
        });
    } else {
        $.FULLTOP.videoStore = new $.BigVideo({baseVideoFrame: $.FULLTOP.wrapperVideo, posterBaseValue: ''});
        $.FULLTOP.videoStore.init();
        $.FULLTOP.videoStore.getPlayer().addEvent("ended", function () {
            $.FULLTOP.videoStore.getPlayer().pause();
            $.FULLTOP.videoStore.getPlayer().currentTime(0);
        });
    }

    //alert('debuggin');
    if (Modernizr.touch) {


        UTILS.getUserAgent();
        if (UTILS.isDevice) {

            $.FULLTOP.openwrapperVideo();

            if ($videoOgv) {
                $.FULLTOP.videoStore.show($videoMp4, {ambient: false, altSource: $videoOgv});
            } else {
                $.FULLTOP.videoStore.show($videoMp4, {ambient: false});

            }


            $.FULLTOP.videoStore.getPlayer().addEvent("progress", function () {
                $('#big-video-vid_html5_api').height($(window).height());
            });
            $.FULLTOP.videoStore.getPlayer().addEvent("loadeddata", function () {
                //alert('h #big-video-vid_html5_api:' +$('#big-video-vid_html5_api').height()+ ' #big-video-vid:' + $('#big-video-vid').height())
            });
            $('#big-video-control-play').hide();
            $('body').append('<div id="playIpad" style="display:none;"></div>');
            $('#playIpad').click(function () {
                $.FULLTOP.videoStore.getPlayer().play();
                $('#big-video-control-play').show();
                $('#playIpad').remove();
            });

        } else {
            $.FULLTOP.videoStore.show($videoPoster);
        }
    } else {


        if ($videoOgv) {
            $.FULLTOP.videoStore.show($videoMp4, {ambient: false, altSource: $videoOgv});
        } else {
            $.FULLTOP.videoStore.show($videoMp4, {ambient: false});
        }


        //$.FULLTOP.initVideo();

    }


    //FLASH MODIFIER
    $.FULLTOP.videoStore.getPlayer().addEvent("play", function () {
        console.log('video play');
        $('#big-video-vid_flash_api,#big-video-vid').height($(window).height());
    });

};

$.FULLTOP.loadVideoPage = function ($videoMp4, $videoOgv, $videoPoster) {


    if ($.FULLTOP.videoStore) {

    } else {
        $.FULLTOP.videoStore = new $.BigVideo({baseVideoFrame: $.FULLTOP.wrapperVideo, posterBaseValue: ''});
        $.FULLTOP.videoStore.init();
        $.FULLTOP.videoStore.getPlayer().addEvent("ended", function () {
            $.FULLTOP.videoStore.getPlayer().pause();
            $.FULLTOP.videoStore.getPlayer().currentTime(0);
        });
    }

    //alert('debuggin');
    if (Modernizr.touch) {


        UTILS.getUserAgent();
        if (UTILS.isDevice) {

            $.FULLTOP.openwrapperVideo();

            if ($videoOgv) {
                $.FULLTOP.videoStore.show($videoMp4, {ambient: false, altSource: $videoOgv});
            } else {
                $.FULLTOP.videoStore.show($videoMp4, {ambient: false});

            }


            $.FULLTOP.videoStore.getPlayer().addEvent("progress", function () {
                $('#big-video-vid_html5_api, object').height($(window).height());
            });
            $.FULLTOP.videoStore.getPlayer().addEvent("loadeddata", function () {
                //alert('h #big-video-vid_html5_api:' +$('#big-video-vid_html5_api').height()+ ' #big-video-vid:' + $('#big-video-vid').height())
            });
            $('#big-video-control-play').hide();
            $('body').append('<div id="playIpad" style="display:none;"></div>');
            $('#playIpad').click(function () {
                $.FULLTOP.videoStore.getPlayer().play();
                $('#big-video-control-play').show();
                $('#playIpad').remove();
            });

        } else {
            $.FULLTOP.videoStorePage.show($videoPoster);
        }
    } else {
        $.FULLTOP.openwrapperVideoPage();

        if ($videoOgv) {
            $.FULLTOP.videoStorePage.show($videoMp4, {ambient: false, altSource: $videoOgv});
        } else {
            $.FULLTOP.videoStorePage.show($videoMp4, {ambient: false});
        }

        //$.FULLTOP.initVideo();

    }

};

$.FULLTOP.loadVideo2 = function ($videoMp4, $videoOgv, $videoPoster) {
    var videoOutput = '<!-- This video element tells the browser to display the default control set, to use a specified poster image which will display before the user plays the video, and to only preload the videos metadata (e.g. video duration)';
    videoOutput += 'NOTE: Internet Explorer 9 and 10 will ignore the poster image if any of the video is loaded. To force these browsers to support the poster image, set preload="none" -->';
    videoOutput += '<video controls poster="' + $videoPoster + '" preload="metadata"  height="100%" width="100%" autoplay="autoplay" style="position:absolute; left:0px; top:0px; width:100%; height:100%;">';
    videoOutput += '<!-- Provide multiple video sources for cross-browser support -->';

    videoOutput += '<!-- MP4 source for Chrome, Safari, Internet Explorer 9+, iOS and Android';
    videoOutput += 'NOTE: remove the type attribute from the MP4 <source> element to ensure older Android support -->';
    videoOutput += '<source src="' + $videoMp4 + '" type="video/mp4" />';

    //videoOutput += '<!-- WebM source for FireFox and Opera (also Chrome and Internet Explorer 9+) -->';
    //videoOutput += '<source src="url-to-video.webm" type="video/webm" />';

    if ($videoOgv) {
        videoOutput += '<!-- Include an Ogg video file to support Firefox 3.5 and 3.6 -->';
        videoOutput += '<source src="' + $videoOgv + '" type="video/ogg" />';
    }
    videoOutput += '<!-- Provide a Flash fallbackfor browsers that dont support HTML5 video, e.g. Internet Explorer 6-7.';
    videoOutput += 'This uses the Google Player to play the MP4 file. Set the height and width attributes to the correct values. -->';
    videoOutput += '<object type="application/x-shockwave-flash" data="player.swf?videoUrl=' + $videoMp4 + '" height="100%" width="100%" style="position:absolute; left:0px; top:0px; width:100%; height:100%;">';
    videoOutput += '<param name="movie"	value="player.swf?videoUrl=' + $videoMp4 + '">';
    videoOutput += '</object>';

    videoOutput += '<!-- Add a downloadable link for users who do not have a HTML5 video capable browser, nor Flash installed';
    videoOutput += 'NOTE: This link will be displayed even if the user has Flash installed -->';
    videoOutput += '<a href="' + $videoMp4 + '">Download MP4 video</a>';
    videoOutput += '</video>';
    $($.FULLTOP.wrapper).append(videoOutput);
}

$.FULLTOP.initVideo = function () {
    $('#big-video-vid,video').css('height', $(window).height() + 'px');
    $('#big-video-vid,video').css('width', $(window).width() + 'px');
};

$.FULLTOP.killVideo = function () {
    /*$.FULLTOP.videoStore = null;
     $('#big-video-wrap').empty();
     $('#big-video-wrap').remove();
     $($.FULLTOP.wrapper).empty();*/
};

$.FULLTOP.videoLink = function () {
    $('.slides .pics').on("click", ".videoElement", function (e) {
        e.preventDefault();
        console.log('its a video: ' + $(this).attr('data-mp4'));
        //$('#fullUpVideo,#fullUpWrapperCloseVideo').show();
        //$('#big-video-wrap').css('top','0px');

        //$.FULLTOP.loadVideoPage($(this).attr('data-mp4'), $(this).attr('data-webm'), $(this).attr('data-poster'));
        //
        $('#fullUpWrapperVideo, #fullUpVideo, #fullUpWrapperCloseVideo').css('display', 'block');

        TweenLite.to($('#fullUpWrapperVideo'), 1, {css: {top: "0%"}, onComplete: function () {
            $('#fullUpWrapperCloseVideo').slideDown('fast');
        }});
        $.FULLTOP.loadVideo($(this).attr('data-mp4'), $(this).attr('data-webm'), $(this).attr('data-poster'));

    });
}
$.FULLTOP.videoLink();